#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "read_string.h"
#include <crtdbg.h>

void main(int count, const char *values[])
{
	int n,j,i = 0;
	int schet = 0;
	int len;

	int simbol;

	FILE *file_input;
	FILE *file_output;
	char *key = NULL;
	
	
	file_input =  fopen(values[1], "r");
	file_output = fopen(values[2], "w");

	if (count !=3)
	{			
		printf("fail arguments,,, ERROR\n");
		return;
	}
	
	
	
	printf("vvedite key\n");
	key = read_string(stdin, '\n');
	
	
	len = strlen(key);

	
	while(1)
	{
		simbol = fgetc(file_input);
		if (simbol == EOF)
			break;

		fputc(simbol ^ key[i % len], file_output);
		i++;
	}

	fclose(file_input);
	fclose(file_output);
	system("pause");
	free (key);
	_CrtDumpMemoryLeaks();
}


	